﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;

namespace NewRetail.Application.DataAccess
{
    public class NewRetailDataSeeder : IDataSeedContributor, ITransientDependency
    {
        private readonly IServiceProvider serviceProvider;
        public NewRetailDataSeeder(IServiceProvider serviceProvider)
        {
            this.serviceProvider = serviceProvider;
        }

        public async Task SeedAsync(DataSeedContext context)
        {
            using var s = this.serviceProvider.CreateScope();
            using var db = s.ServiceProvider.GetRequiredService<NewRetailDbContext>();
            await db.Database.EnsureCreatedAsync();
        }
    }
}
